<<<<<<< HEAD
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Controll : MonoBehaviour, ISceneController, IUserAction
{
    private int gamestate = 0;
    private int round = 1;
    private int score = 0;
    private float time = 2f;
    private float i = 0;
    public UserGUI User;
    public MySceneActionManager actionManager;
    public DiskFactory diskfactory;
    void Start()
    {
        SSDirector director = SSDirector.GetInstance();
        director.CurrentSceneController = this;
        User = gameObject.AddComponent<UserGUI>() as UserGUI;
        diskfactory = Singleton<DiskFactory>.Instance;
        actionManager = gameObject.AddComponent<MySceneActionManager>() as MySceneActionManager;
    }

    void Update()
    {
        if (gamestate == 2)
        {
            gamestate = 1;
        }

        if (gamestate == 1)
        {
            if (i >= time)
            {
                if (score > 10 && round == 1)
                {
                    time -= 0.3f;
                    round = 2;
                }
                else if (score > 20 && round == 2)
                {
                    time -= 0.5f;
                    round = 3;
                }
                else if (score > 30 && round == 3)
                {
                    time += 0.3f;
                    round = 4;
                }
                SendDisk();
                i = 0;
            }
            i += Time.deltaTime;
        }

    }
    public void LoadResources()
    {

    }
    public void SendDisk()
    {
        Disk disk = diskfactory.GetDisk();
        if (round == 1)
        {
            disk.Power = Random.Range(2.5f, 3.5f);
            disk.Angle = Random.Range(10f, 30f);
            disk.Gravity = Random.Range(-0.5f, -0.8f);
            disk.disk.transform.position = new Vector3(-10, Random.Range(-3f, 2f), 0);
        }
        else if (round == 2)
        {
            disk.Power = Random.Range(3.5f, 5f);
            disk.Angle = Random.Range(5f, 35f);
            disk.Gravity = Random.Range(-0.6f, -1f);
            disk.disk.transform.position = new Vector3(-10, Random.Range(-4f, 1f), 0);
        }
        else if (round == 3)
        {
            disk.Power = Random.Range(5.5f, 8f);
            disk.Angle = Random.Range(5f, 35f);
            disk.Gravity = Random.Range(-1f, -1.5f);
            disk.disk.transform.position = new Vector3(-10, Random.Range(-5f, 3f), 0);
        }
        else if (round == 4)
        {
            disk.Power = Random.Range(7f, 10f);
            disk.Angle = Random.Range(5f, 35f);
            disk.Gravity = Random.Range(-2f, -2.5f);
            disk.disk.transform.position = new Vector3(-10, Random.Range(-5f, 2f), 0);
            Disk disk2 = diskfactory.GetDisk();
            disk2.Power = Random.Range(6f, 8f);
            disk2.Angle = Random.Range(5f, 35f);
            disk2.Gravity = Random.Range(-1f, -3f);
            disk2.disk.transform.position = new Vector3(-10, Random.Range(-4.5f, 1f), 0);
            actionManager.fly_disk(disk2);
        }
        actionManager.fly_disk(disk);
    }
    public void Restart()
    {
        score = 0;
        gamestate = 2;
    }
    public void Stopgame()
    {
        gamestate = 0;
        round = 1;
        time = 2f;
    }

    public void Startgame()
    {
        gamestate = 2;
    }

    public bool Hit()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        if (Physics.Raycast(ray, out hit))
        {
            if (hit.collider.gameObject.transform.position.x < 3 && gamestate > 0) score += 2;
            else if (hit.collider.gameObject.transform.position.x >= 3 && gamestate > 0) score += 1;
            hit.collider.gameObject.transform.position = new Vector3(-10, -11, 0);
            diskfactory.FreeDisk(hit.collider.gameObject);
            return true;
        }
        return false;
    }
    public int Getscore()
    {
        return score;
    }
=======
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Controll : MonoBehaviour, ISceneController, IUserAction
{
    private int gamestate = 0;
    private int round = 1;
    private int score = 0;
    private float time = 2f;
    private float i = 0;
    public UserGUI User;
    public MySceneActionManager actionManager;
    public DiskFactory diskfactory;
    void Start()
    {
        SSDirector director = SSDirector.GetInstance();
        director.CurrentSceneController = this;
        User = gameObject.AddComponent<UserGUI>() as UserGUI;
        diskfactory = Singleton<DiskFactory>.Instance;
        actionManager = gameObject.AddComponent<MySceneActionManager>() as MySceneActionManager;
    }

    void Update()
    {
        if (gamestate == 2)
        {
            gamestate = 1;
        }

        if (gamestate == 1)
        {
            if (i >= time)
            {
                if (score > 10 && round == 1)
                {
                    time -= 0.3f;
                    round = 2;
                }
                else if (score > 20 && round == 2)
                {
                    time -= 0.5f;
                    round = 3;
                }
                else if (score > 30 && round == 3)
                {
                    time += 0.3f;
                    round = 4;
                }
                SendDisk();
                i = 0;
            }
            i += Time.deltaTime;
        }

    }
    public void LoadResources()
    {

    }
    public void SendDisk()
    {
        Disk disk = diskfactory.GetDisk();
        if (round == 1)
        {
            disk.Power = Random.Range(2.5f, 3.5f);
            disk.Angle = Random.Range(10f, 30f);
            disk.Gravity = Random.Range(-0.5f, -0.8f);
            disk.disk.transform.position = new Vector3(-10, Random.Range(-3f, 2f), 0);
        }
        else if (round == 2)
        {
            disk.Power = Random.Range(3.5f, 5f);
            disk.Angle = Random.Range(5f, 35f);
            disk.Gravity = Random.Range(-0.6f, -1f);
            disk.disk.transform.position = new Vector3(-10, Random.Range(-4f, 1f), 0);
        }
        else if (round == 3)
        {
            disk.Power = Random.Range(5.5f, 8f);
            disk.Angle = Random.Range(5f, 35f);
            disk.Gravity = Random.Range(-1f, -1.5f);
            disk.disk.transform.position = new Vector3(-10, Random.Range(-5f, 3f), 0);
        }
        else if (round == 4)
        {
            disk.Power = Random.Range(7f, 10f);
            disk.Angle = Random.Range(5f, 35f);
            disk.Gravity = Random.Range(-2f, -2.5f);
            disk.disk.transform.position = new Vector3(-10, Random.Range(-5f, 2f), 0);
            Disk disk2 = diskfactory.GetDisk();
            disk2.Power = Random.Range(6f, 8f);
            disk2.Angle = Random.Range(5f, 35f);
            disk2.Gravity = Random.Range(-1f, -3f);
            disk2.disk.transform.position = new Vector3(-10, Random.Range(-4.5f, 1f), 0);
            actionManager.fly_disk(disk2);
        }
        actionManager.fly_disk(disk);
    }
    public void Restart()
    {
        score = 0;
        gamestate = 2;
    }
    public void Stopgame()
    {
        gamestate = 0;
        round = 1;
        time = 2f;
    }

    public void Startgame()
    {
        gamestate = 2;
    }

    public bool Hit()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        if (Physics.Raycast(ray, out hit))
        {
            if (hit.collider.gameObject.transform.position.x < 3 && gamestate > 0) score += 2;
            else if (hit.collider.gameObject.transform.position.x >= 3 && gamestate > 0) score += 1;
            hit.collider.gameObject.transform.position = new Vector3(-10, -11, 0);
            diskfactory.FreeDisk(hit.collider.gameObject);
            return true;
        }
        return false;
    }
    public int Getscore()
    {
        return score;
    }
>>>>>>> af278523501920b14a6298f03aa4bd9ad9d33c2d
}